﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using DatabaseAccessLayer;
using System.Web.Script.Services;
namespace WebApplication.ManageAccount
{
    /// <summary>
    /// Summary description for CountryDetails
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
     [System.Web.Script.Services.ScriptService]
    public class CountryDetails : System.Web.Services.WebService
    {

        List<DatabaseAccessLayer.Country.AddressList> Address = Country.GetSearchList();
        List<DatabaseAccessLayer.Country.Property> property = Country.GetProperty();
        List<DatabaseAccessLayer.Country.PriceModes> PriceModes = Country.GetPriceMode();
        List<DatabaseAccessLayer.Country.PriceModes> Codes = Country.GetPriceMode();

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public List<string> GetCountry()
        {
            var Country = (from add in Address
                           orderby add.Country
                           select string.Concat(add.Country)

                              ).Distinct();
            return Country.ToList();
        }


        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        [WebMethod]
        public List<string> GetCity(string Country)
        {
            var City = (from C in Address
                        where C.Country == Country
                        select string.Concat(C.City)).Distinct();
            return City.ToList();

        }
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        [WebMethod]
        public string GetCountryCode(string Country)
        {
            string itemValue = "";
            var CountryCode = (from C in Address
                               where C.Country == Country
                               select string.Concat(C.CountryCode)).Distinct();
            foreach (var item in CountryCode)
            {
                itemValue = item.ToString();
            }
            return itemValue;

        }
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        [WebMethod]
        public List<string> GetProperty()
        {
            var Prop = (from C in property
                        select string.Concat(C.Prop)).Distinct();
            return Prop.ToList();

        }
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        [WebMethod]
        public List<string> GetPropertyType(string Property)
        {
            var Prop = (from C in property
                        where C.Prop == Property
                        select string.Concat(C.Type));
            return Prop.ToList();

        }

        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        [WebMethod]
        public List<string> GetPriceMode()
        {
            var Prop = (from C in PriceModes
                        select string.Concat(C.PriceMode));
            return Prop.ToList();

        }
    }
}
